package gene.core;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import gene.core.collection.ComponentCollection;
import gene.core.util.Camera;

/**
 *
 * @author Vinícius
 */
public abstract class Scene {

    protected static int tick              = 0;
    public  ComponentCollection components = null;
	private boolean  visible_initialized_inputAllowed [] = {false,false,true};
    public  boolean  visible              = true;
    private boolean  initialized          = false;
    private boolean  inputAllowed         = true;
    public static final int STATE_RUNNING = 1;
    public static final int STATE_PAUSED  = 2;
    private int state                     = -1;
    private int lastState                 = -1;
    public static Camera camera = new Camera(0,0,Core.getInstance().getW(),Core.getInstance().getH(),0,0);
    
    /** method to initialize the class
     */
    public void initialize(){
        //initialized=true;
		visible_initialized_inputAllowed [1] = true;
    }
	
	public void setVisible(boolean visible){
    	visible_initialized_inputAllowed [0] = visible;
    }
	
	public void allowInput(boolean allow){
        //initialized=true;
		visible_initialized_inputAllowed [2] = allow;
    }
	
	public boolean IsInitialize(){
        return visible_initialized_inputAllowed [1];
    }
	
	public boolean getVisible(){
    	return visible_initialized_inputAllowed [0];
    }
	
	public boolean getAllowInput(){
        return visible_initialized_inputAllowed [2] ;
    }
	

    /**
     * abstract method to pause the current Screen
     */
    public abstract void pause() ;
    /**
     * abstract method to resume the current Screen
     */
    public abstract void resume();
    /**
     * update the actions on the current screen 
     */
    public abstract void update();
    /**
     * destroy a tela
     */
    public abstract void destroy();
    /**
     * pinta a tela
     */
    public abstract void paint();
    /** Restart screen state*/
    public abstract void clear();
    /**
     * Screen's constructor.
     * @param setToCoreScreen  Change the anyone screen to this on <code>Core</code> class
     */
    public Scene(boolean setToCoreScreen){
        //verifica se o core foi inicializado
        if(!Core.getInstance().isInitialized()){
           new Exception("Core not initialized exception");
        }
        //verifica se quer jogar essa instancia no Core
        if(setToCoreScreen){
            init();
            Core.getInstance()._screen = this;//setScreen(this);
        }
    }
    /**  */
    public Scene(){
    init();
    }

    protected void init(){
        components = new ComponentCollection();
    }
    public void destroyScene(){
    if(Core.filesoundPlayer != null){
        Core.filesoundPlayer.stopMusic();
    }
    //Component.collectionDestroy();
    components.destroy();
    visible_initialized_inputAllowed = null;
    this.destroy();
    }
}
